﻿using System.Collections;

namespace CSharpPro2._1023;

public class Demo
{
    public static void TestPrint()
    {
        /*
        int[] arr1 = new int[5];
        arr1[0] = 1;
        arr1[4] = 5;
        //Console.WriteLine(arr1[6]);
        for (int i = 0; i < arr1.Length; i++)
        {
            Console.Write(arr1[i] + "\t");
        }

        string[] arr2 = new string[5];
        arr2[0] = "Hello";
        arr2[4] = "World";
        for (int i = 0; i < arr2.Length; i++)
        {
            Console.Write(arr2[i] + "\t");
        }

        int[] arr3 = {1, 2, 3, 4, 5, 6};
        Console.WriteLine(arr3[4]);

        int[,] arr4 = new int[3,3];
        arr4[0, 0] = 1;
        arr4[1,1] = 2;
        arr4[2,2] = 3; //代表的是右下角
        int[,] arr5 =
        {
            { 1, 2, 3 },
            { 4, 5, 6 },
            { 6, 7, 8 },
        };
        int[] arr6 = { 55, 894, 5, 484, 22, };
        Array.Sort(arr6);
        Array.Reverse(arr6);
        Console.WriteLine();
        foreach (int i in arr6)
        {
            Console.Write(i + "\t");
        }

        ArrayList list = new ArrayList();
        list.Add(1);
        list.Add(2);
        list.Add(3);
        list.Add("abc");
        Console.WriteLine("\n" + list.Count);
        Console.WriteLine();

        foreach (object i in list)
        {
            Console.Write(i + "\t");
        }

        list.Contains("abc");
        Console.WriteLine();

        Hashtable hashtable = new Hashtable();
        hashtable.Add("name", "张三");
        hashtable.Add("age", 18);
        hashtable.Add("sex", "男");
        foreach (DictionaryEntry entry in hashtable)
        {
            Console.Write(entry.Key + "\t" + entry.Value);
            Console.WriteLine();
        }

        hashtable.Remove("name");
        */

        //冒泡排序
        int[] arr = { 54, 9, 64, 88, 32, 8, 14 };
        int temp;
        for (int i = 0; i < arr.Length - 1; i++)
        {
            for (int j = 0; j < arr.Length - i - 1; j++)
            {
                if (arr[j] > arr[j + 1])
                {
                    temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }

        foreach (int i in arr)
        {
            Console.Write(i + "\t");
        }
    }

}